package com.weiaibenpao.demo.chislim.presenter;

import com.weiaibenpao.demo.chislim.base.BasePresenter;
import com.weiaibenpao.demo.chislim.bean.MarathonBean;
import com.weiaibenpao.demo.chislim.retrofit.RetrofitUtils;
import com.weiaibenpao.demo.chislim.retrofit.rx.NetWorkTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.SimpleObserver;
import com.weiaibenpao.demo.chislim.view.MarathonView;

/**
 * Created by wlx on 2018/1/8.
 */

public class MarathonPresenter extends BasePresenter<MarathonView> {
    public void getMarathonList(int page,int pageSize){
        RetrofitUtils.getAPIService().getMarathon(page,pageSize)
                .compose(new NetWorkTransformer<MarathonBean>())
//                .compose(new LoadingTransformer<MarathonBean>(mContext))
                .subscribe(new SimpleObserver<MarathonBean>(mCompositeDisposable) {
                    @Override
                    public void call(MarathonBean marathoListBean) {
                        getView().getMarathonListSuccess(marathoListBean);
                    }
                });
    }
    public void getMyMarathonList(int userId,int page,int pageSize){
        RetrofitUtils.getAPIService().getMMarathon(userId,page,pageSize)
                .compose(new NetWorkTransformer<MarathonBean>())
//                .compose(new LoadingTransformer<MarathonBean>(mContext))
                .subscribe(new SimpleObserver<MarathonBean>(mCompositeDisposable) {
                    @Override
                    public void call(MarathonBean marathoListBean) {
                        getView().getMarathonListSuccess(marathoListBean);
                    }
                });
    }
}
